<?php

/**
 * The plugin bootstrap file
 *
 * This file is read by WordPress to generate the plugin information in the plugin
 * admin area. This file also includes all of the dependencies used by the plugin,
 * registers the activation and deactivation functions, and defines a function
 * that starts the plugin.
 *
 * @link              https://gitee.com/sliver-ring_admin/larapress
 * @since             1.0.0
 * @package           Wp_Lara_Press
 *
 * @wordpress-plugin
 * Plugin Name:       Larapress
 * Plugin URI:        https://gitee.com/sliver-ring_admin/larapress
 * Description:       一款WordPressAPI插件，该插件集成了Laravel框架，可以实现WordPress与Laravel的深度结合。并提供市面常见的各种应用场景的API接口。
 * Version:           1.0.0
 * Author:            银二
 * Author URI:        https://gitee.com/sliver-ring_admin/larapress
 * License:           GPL-2.0+
 * License URI:       http://www.gnu.org/licenses/gpl-2.0.txt
 * Text Domain:       wp-lara-press
 * Domain Path:       /languages
 */

// If this file is called directly, abort.
if (! defined('WPINC')) {
	die;
}

/**
 * Currently plugin version.
 * Start at version 1.0.0 and use SemVer - https://semver.org
 * Rename this for your plugin and update it as you release new versions.
 */
define('WP_LARA_PRESS_VERSION', '1.0.0');
define('WP_LARA_PRESS_API_PREFIX', 'larapress-api');
define('WP_LARA_PRESS_PLUGIN_BASIS_PATH', plugin_dir_path(__FILE__));


// 定义 Redux Framework 常量
if (!defined('REDUX_PLUGIN_FILE')) {
	define('REDUX_PLUGIN_FILE', __FILE__);
}


// 初始化 Redux Framework
if (!class_exists('ReduxFramework')) {
	// 检查 PHP 版本
	require_once WP_LARA_PRESS_PLUGIN_BASIS_PATH . 'admin/redux-framework/redux-core/inc/classes/class-redux-php.php';
	if (Redux_PHP::version_met()) {
		// 加载 Redux Core
		require_once WP_LARA_PRESS_PLUGIN_BASIS_PATH . 'admin/redux-framework/redux-core/framework.php';
		// 设置 Redux 作为插件模式
		if (isset(Redux_Core::$as_plugin)) {
			Redux_Core::$as_plugin = true;
		}
	}
}

if (file_exists(WP_LARA_PRESS_PLUGIN_BASIS_PATH . 'vendor/autoload.php')) {
	require_once WP_LARA_PRESS_PLUGIN_BASIS_PATH . 'vendor/autoload.php';
}


/**
 * The code that runs during plugin activation.
 * This action is documented in includes/class-wp-lara-press-activator.php
 */
function activate_wp_lara_press()
{
	require_once plugin_dir_path(__FILE__) . 'includes/class-wp-lara-press-activator.php';
	Wp_Lara_Press_Activator::activate();
}

/**
 * The code that runs during plugin deactivation.
 * This action is documented in includes/class-wp-lara-press-deactivator.php
 */
function deactivate_wp_lara_press()
{
	require_once plugin_dir_path(__FILE__) . 'includes/class-wp-lara-press-deactivator.php';
	Wp_Lara_Press_Deactivator::deactivate();
}

register_activation_hook(__FILE__, 'activate_wp_lara_press');
register_deactivation_hook(__FILE__, 'deactivate_wp_lara_press');

/**
 * The core plugin class that is used to define internationalization,
 * admin-specific hooks, and public-facing site hooks.
 */
require plugin_dir_path(__FILE__) . 'includes/class-wp-lara-press.php';

/**
 * Begins execution of the plugin.
 *
 * Since everything within the plugin is registered via hooks,
 * then kicking off the plugin from this point in the file does
 * not affect the page life cycle.
 *
 * @since    1.0.0
 */
function run_wp_lara_press()
{

	$plugin = new Wp_Lara_Press();
	$plugin->run();
}
run_wp_lara_press();
